package generator

import (
	"fmt"
	"strings"
)

// FastLower 首字母小写 大驼峰
func FastLower(s *string) string {
	return fmt.Sprintf("%s%s", strings.ToLower((*s)[:1]), (*s)[1:])
}

// UpperToLine 大写转小写加下划线
func UpperToLine(s *string) string {
	var word = make([]rune, 0)
	for index, char := range *s {
		if index == 0 {
			if char >= 'A' && char <= 'Z' {
				word = append(word, char+32)
				continue
			}
			word = append(word, char)
			continue
		}
		if char >= 'A' && char <= 'Z' {
			word = append(word, '_', char+32)
			continue
		}
		word = append(word, char)
	}
	return string(word)
}
